class SceneMange extends egret.Sprite {
	// 场景控制器的单例
	private static instance: SceneMange;
	// 开始场景
	private beginScene: BeginScene;
	// 游戏场景
	private gameScene: GameScene;
	// 游戏排行榜
	private rankScene: RankScene

	//记录舞台宽度
	public stageHeight: number;

	//记录舞台高度
	public stageWidth: number;

	private model;

	public constructor(height,width) {
		super();
		this.stageHeight = height;
		this.stageWidth = width;
		this.init();
	}
	private init(){
		let deviceInfo = wx.getSystemInfoSync()
		this.model = deviceInfo.model;
		// 实例化两个场景
		this.beginScene = new BeginScene();
		this.rankScene = new RankScene();
		this.gameScene = new GameScene(this.stageHeight,this.stageWidth)

		// 默认添加开始场景
		this.addChild(this.beginScene);
	}
	// 实例化单例获取方法
	public static getInstance(height?,width?): SceneMange{
		if(!SceneMange.instance){
			SceneMange.instance = new SceneMange(height,width);
		}
		return SceneMange.instance;
	}
	// 切换场景
	public changeScene(type){
		// 移除所有显示列表中的对象
		this.removeChildren();
		if(type === 'rankScene' && /iPhone X/.test(this.model)){
			this.y = 100;
		}else {
			this.y = 0;
		}

		// 添加下一个场景
		this.addChild(this[type]);

		if(type == 'rankScene'){
			this.rankScene.reset();
		}

		if(type == 'gameScene'){
			this.gameScene.reset();
		}
	}
}